﻿using System;
using System.Data;
using System.Collections.Generic;
using Ry.Defined;
namespace Ry.Database
{
    public interface DBInterface : IDisposable
    {
        EnumDatabaseType DatabaseType { get; set; }
        string DBVersion { get; set; }
        int Port { get; set; }
        string DataSource { get; set; }
        string UserName { get; set; }
        string Password { get; set; }
        string DBName { get; set; }
        bool DBConnected { get; set; }

        /// <summary>
        /// 是否一直连接数据库  true:每次执行完数据库不断开连接  false:执行完数据库操作断开连接
        /// </summary>
        bool KeepConnect { get; set; }

        int GetDataSet(string sqlString, CommandType commandType, Dictionary<string, object> dictParam, ref DataSet ds);

        int GetDataSet(string sqlString, CommandType commandType, Dictionary<string, object> dictParam, ref DataTable ds);

        int ExecuteNonQuery(string sqlString, CommandType commandType, Dictionary<string, object> dictValue);

        int ExecuteProgram(string programName, Dictionary<string, object> dictParam, out string result);
        int ExecuteProgram(string programName, Dictionary<string, object> dictParam,string outParaName, ref DataTable dt);

        /// <summary>
        /// 删除一个表中的数据
        /// </summary>
        /// <param name="tableName">表名</param>
        /// <param name="fieldName">字段名</param>
        /// <param name="fieldValue">字段值</param>
        /// <returns></returns>
        int DelValues(string tableName, string fieldName, string fieldValue);

        /// <summary>
        /// 单一更新，更新一个表中的一个字段的值
        /// </summary>
        /// <param name="tableName">表名</param>
        /// <param name="updateField">更新字段名称</param>
        /// <param name="fieldValues">字段值</param>
        /// <param name="conditionName">判断字段名称</param>
        /// <param name="conditionValues">字段值</param>
        /// <returns></returns>
        int UpdataOneValues(string tableName, string updateField, string fieldValues, string conditionName, string conditionValues);

        int ConnectDB(string dbSource,int port, string username, string passwd, string dbName, bool immediateConn);
        int ConnectDB();
        int Disconnect();

    }
}
